package logic

import (
	"context"
	"manuscript-service/model/model"

	"manuscript-service/servicerpc/internal/svc"
	"manuscript-service/servicerpc/servicerpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *servicerpc.UserListRequest) (*servicerpc.UserListResponse, error) {
	// todo: add your logic here and delete this line

	var list model.User
	var user []*servicerpc.UserList
	var err error
	if err = list.UserList(model.DB, user); err != nil {
		return nil, err
	}

	return &servicerpc.UserListResponse{
		List: user,
	}, nil
}
